<template>
  <div>
    <div class="">
      <el-row>
        <el-col :xs="24" :sm="10" :md="10" :lg="10" :xl="10">
          <div class="detail_info">
            <div style="margin: 25px 20px 0px 25px">
              <img :src="info.zxlogo" alt="" style="
                  width: 58px;
                  height: 58px;
                  border-radius: 8px;
                " />
            </div>
            <div style="margin-top: 16px;">
              <span class="detail_title">{{ info.nickname }}</span>
              <div class="detail_text">
                <span>{{ info.mini_version }}</span>
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="14" :md="14" :lg="14" :xl="14">
          <div class="but_count">
            <el-button type="button" class="preview" @click="gotodown()">预览</el-button>
            <el-button type="button" class="upnew" @click="gotoUploadNew()">上传新版本</el-button>
          </div>
        </el-col>
      </el-row>
    </div>
    <el-form :model="ruleForm" label-width="100px" class="demo-ruleForm" :label-position="labelPosition"
      style="margin-top: 43px; padding-left: 30px; padding-right: 30px">
      <el-form-item required>
        <el-col :xs="24" :sm="9" :md="5" :lg="5" :xl="5">
          <el-form-item prop="date1">
            <el-date-picker type="date" placeholder="选择起始日期" v-model="ruleForm.date1" style="width: 100%">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col class="line" :xs="0" :sm="1" :md="1" :lg="1" :xl="1">-</el-col>
        <el-col :xs="24" :sm="9" :md="5" :lg="5" :xl="5">
          <el-form-item prop="date2" class="data2">
            <el-date-picker type="date" placeholder="选择结束日期" v-model="ruleForm.date2" style="width: 100%">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="2" :md="5" :lg="5" :xl="5">
          <el-form-item prop="date3" style="margin-left:10px;" class="select_but">
            <el-button type="primary" @click="submitForm('ruleForm')" class="select">查询</el-button>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="5" :lg="5" :xl="5">
          <el-form-item>
            <div class="count">
              累计总下载量<span class="number">{{ allDownCount }}</span>次
            </div>
          </el-form-item>
        </el-col>
      </el-form-item>

      <table class="table table-bordered">
        <thead>
          <tr>
            <th>时间</th>
            <th>应用名称</th>
            <th>版本</th>
            <th>大小</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in dataList" :key="index">
            <td>{{ item.addtime }}</td>
            <td>{{ item.nickname }}</td>
            <td>{{ item.type }}</td>
            <td>{{ item.zsize }}</td>
          </tr>
        </tbody>
      </table>
    </el-form>
  </div>
</template>

<script>
  import filters from "../../../utils/filters";
  export default {
    //import引入的组件需要注入到对象中才能使用
    components: {},
    filters: filters,
    data() {
      //这里存放数据
      return {
        appUrl: "../../../static/App图标.png",
        info: [],
        labelPosition: "left",
        allDownCount: {}, //下载次数
        ruleForm: {
          date1: "",
          date2: "",
        },
        dataList: [], //表格数据接收
      };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      getList() {
        var params = new URLSearchParams();
        params.append("appid", this.$route.query.appID);
        params.append("startTime", this.ruleForm.date1);
        params.append("endTime", this.ruleForm.date2);
        this.$post(this.API.Application_downlist, params).then((res) => {
          let data = res.data;
          this.info = data.info;
          this.dataList = data.list;
          this.allDownCount = data.allDownCount;
        });
      },
      goUrl(path, name) {
        sessionStorage.setItem("currentTab", "first");
        this.$router.push({
          path: path,
          name: name,
        });
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert("submit!");
          } else {
            // console.log("error submit!!");
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      //上传新版本
      gotoUploadNew() {
        let appID = this.appID;
        this.$router.push({
          path: "adhibition",
          name: "adhibition",
          query: {
            appID: appID,
          },
        });

        window.scrollTo(0, 0);
        sessionStorage.setItem("currentTab_title", "adhibition");
        sessionStorage.setItem("setMenuIndex_application", 0); //设置我的应用左侧菜单选中项
        location.reload();
      },
      //预览
      // showDownPage(){
      //   let down_url = this.info.down_url;
      //   window.open(down_url, '_blank');
      // },
      gotodown() {
        var temp = window.open('_blank')
        temp.location.href = "https://down.lmffw.com/" + encodeURIComponent(this.info.shorturl);
      }
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.getList();
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
  };

</script>
<style scoped>
  .count {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;
  }

  .number {
    font-size: 22px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #ff7226;
    line-height: 22px;
    margin: 0px 3px 0px 3px;
  }

  /* div>>>.table > thead > tr > th {
  padding: 0px;
  border: 1px solid #ddd!important;
} */
  div>>>.select {
    width: 80px;
    height: 40px;
    background: #ff7226;
    border-radius: 4px;
    border: 0px;
  }

  div>>>.el-form-item__content {
    margin-left: 0px !important;
  }

  .line {
    text-align: center;
    width: 30px;
  }

  .orderHeader {
    display: flex;
    justify-content: space-between;
    height: 80px;
    padding: 18px 20px;
  }

  .flexJustifyStart {
    display: flex;
    justify-content: start;
    align-items: center;
  }

  .block>>>.el-date-editor .el-range__icon {
    margin-left: -5px !important;
    line-height: 18px !important;
  }

  .orderHeader>>>.el-form-item__content {
    line-height: 40px !important;
  }

  .flexAlginCenter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    width: 100%;
  }

  .orderBody {
    height: 550px;
  }

  div>>>.el-card {
    border: none;
  }

  div>>>.el-progress-bar {
    width: 200px;
  }

  /* 按钮 */
  .buy {
    background: -webkit-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: -o-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: -moz-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: linear-gradient(-135deg, #ff9d68, #ff7226);
    color: #fff;
    font-size: 16px;
  }

  .cell span {
    width: 1px;
    /*根据自己项目进行定义宽度*/
    overflow: hidden;
    /*设置超出的部分进行影藏*/
    text-overflow: ellipsis;
    /*设置超出部分使用省略号*/
    white-space: nowrap;
    /*设置为单行*/
  }

  .box1 {
    width: 100px;
    height: 50px;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    /* border-right: 1px solid #E0E0E0; */
  }

  .box1:first-child {
    border-right: 1px solid #e0e0e0;
  }

  .box2 {
    margin: 0px 20px;
  }

  .detail_info {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .detail_title {
    width: 36px;
    height: 18px;
    font-size: 18px;
    font-family: PingFang-SC-Medium, PingFang-SC;
    font-weight: 500;
    color: #fff;
  }

  .detail_text {
    height: 12px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    margin-top: 5px;
  }

  .detail_text span:first-child {
    margin-left: 0px;
  }

  .detail_text span {
    margin-left: 22px;
    color: #999;
  }

  .table>thead>tr>th {
    border: none;
    border-bottom: 1px solid #272727;
    text-align: center;
    width: 25%;
    background-color: #272727;
    color: #fff;
    /* font-size: 16px;
  font-family: PingFang-SC-Medium, PingFang-SC;
  font-weight: 500;
  color: #040404;
  line-height: 16px; */
  }

  .table-bordered>tbody>tr>td {
    border: none;
    border-bottom: 1px solid #272727;
    text-align: center;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;
    line-height: 16px;
  }

  div>>>.preview,
  .merge {
    border: 2px solid #ff7226;
    color: #ff7226;
  }

  .preview:hover {
    background-color: #ff7226;
    color: #fff;
  }

  .upnew:hover {
    border: 2px solid #ff7226;
    background-color: #fff;
    color: #ff7226;
  }

  .upnew {
    border: 2px solid #ff7226;
    background-color: #ff7226;
    color: #fff;
  }

  div>>>.el-tabs--border-card>.el-tabs__header {
    background-color: transparent;
    border: 1px solid #ff7226;
    width: 935px;
  }

  div>>>.el-tabs--border-card {
    border: none;
    box-shadow: none;
    background: transparent;
  }

  div>>>.el-tabs__nav-wrap {
    height: 50px;
  }

  div>>>.el-tabs__item {
    height: 50px;
    line-height: 50px;
  }

  div>>>.el-tabs__item {
    padding: 0px 127px;
  }

  div>>>.el-tabs--top.el-tabs--border-card>.el-tabs__header .el-tabs__item:nth-child(2) {
    padding-left: 127px;
  }

  div>>>.el-tabs--top.el-tabs--border-card>.el-tabs__header .el-tabs__item:last-child {
    padding-right: 127px;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active {
    color: #fff;
    background-color: #ff7226;
    border-right-color: #ff7226;
    border-left-color: #ff7226;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active:hover {
    color: #fff;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item {
    color: #ff7226;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item:hover {
    color: #ff7226;
  }

  .demo-ruleForm {
    margin-left: -10px;
  }

  .but_count {
    display: flex;
    justify-content: flex-end;
    margin-right: 20px;
    margin-top: 30px;
  }

  /* 媒体查询 */
  @media (max-width: 992px) {
    .count {
      margin-top: 20px;
      font-size: 14px;
    }
  }

  @media (max-width: 768px) {
    .but_count {
      display: flex;
      justify-content: flex-start;
      margin-left: 20px;
      margin-bottom: -20px;
    }

    .count {
      margin-top: 20px;
      font-size: 14px;
    }

    .data2 {
      margin-top: 20px;
    }

    .select_but {
      margin-top: 20px;
    }
  }

  @media (max-width: 576px) {
    .but_count {
      display: flex;
      justify-content: flex-start;
      margin-left: 28px;
      margin-bottom: -20px;
    }

    .select_but {
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 20px;
    }

    .count {
      margin-top: 20px;
      font-size: 14px;
    }

    .data2 {
      margin-top: 20px;
    }

  }

  @media (max-width: 414px) {
    .but_count {
      display: flex;
      justify-content: center;
      margin-bottom: -20px;
      margin-left: -140px;
    }

    .el-button {
      padding: 8px 15px;
    }

  }

  @media (max-width: 375px) {
    .but_count {

      margin-bottom: -20px;
      margin-left: -100px;
    }

    .el-button {
      padding: 8px 15px;
    }

  }

  .demo-ruleForm>>>.el-form-item .el-dropdown {
    border: 1px solid #272727 !important;
  }

  .demo-ruleForm>>>.el-form-item .el-dropdown .el-dropdown-link {
    color: #aeacaa;
  }

  .demo-ruleForm>>>.el-form-item .el-form-item__content .el-input .el-input__inner {
    border: 1px solid #272727 !important;
    background-color: #272727;
    color: #aeacaa;
  }

  .demo-ruleForm>>>.el-input .el-input-group__append {
    border: 1px solid #272727 !important;
    background-color: #272727;
  }

  .demo-ruleForm>>>.table-bordered {
    border: 1px solid #272727;
  }

</style>
